package com.wnxy.sddfp.search.controller;

import com.wnxy.sddfp.common.model.page.PageVo;
import com.wnxy.sddfp.common.result.Result;
import com.wnxy.sddfp.search.model.query.BorrowRecordSearchQuery;
import com.wnxy.sddfp.search.model.vo.BorrowRecordIndexVo;
import com.wnxy.sddfp.search.service.SearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/search")
@Api(tags = "搜索微服务")
public class SearchController {

    private final SearchService searchService;
    public SearchController(SearchService searchService) {
        this.searchService = searchService;
    }

    @PostMapping("/borrowRecord")
    @ApiOperation("搜索")
    public Result<PageVo<BorrowRecordIndexVo>> search(@RequestBody BorrowRecordSearchQuery query) {
        PageVo<BorrowRecordIndexVo> pageVo = searchService.search(query);
        return Result.ok(pageVo);
    }
}
